﻿<?php
if(!defined('IN_PHPSCUP'))exit('hacking'); 
class LoginApp extends BaseApp
{
    function index()
    {
		$GLOBALS['Lang']->_get_lang('login');	
	 	$categorydata = & $GLOBALS['SCup']->_get_category_data('prot');
		
        $this->assign('categorydata', $categorydata);			
		require(ROOT_PATH . '/lib/nav.lib.php');
		
		$nav = new Nav($GLOBALS['SCup']->SCup_nav_file);
		
        $this->assign('navigation', $nav->_get_nav());	
        $pic_data = include(ROOT_PATH . '/data/cache/rollpic_'.trim($GLOBALS['Lang']->_lang_tp).'.php'); 
		$this->assign('pic_data', $pic_data);		
        $this->assign('langdata', $GLOBALS['Lang']->_get_lang_typesdata());	 	    
        $this->assign('view_charset', VIEW_CHARSET);	
        $this->assign('page_title', SITE_TITLE);
        $this->assign('page_description', SITE_DESCRIPTION);
        $this->assign('page_keywords', SITE_KEYWORDS);	
		$this->assign('bg_pic_url',$GLOBALS['SCup']->SCup_name.'/view/'.VIEW_TYPE .'/style/'.CSS_TYPE.'/');			
        $this->assign('login_icon', $GLOBALS['SCup']->SCup_user_checking);
        $this->assign('langtype', trim($GLOBALS['Lang']->_lang_tp));
	        $this->assign('site_url',SITE_URL);	
		
        $this->display('login.view.html');
    }

    function reg()
    {
		if ((!ALLOW_REGISTER) && ($GLOBALS['SCup']->SCup_name != 'admin')) 
		{   
	        $notice = &get_message(array('msg'=>CLOSE_REGISTER_REASON,'url'=>'','title'=>'提示'));
	        $notice ->display();
		}	
	
		$GLOBALS['Lang']->_get_lang('login');	
	 	$categorydata = & $GLOBALS['SCup']->_get_category_data('prot');
		
        $this->assign('categorydata', $categorydata);			
		require(ROOT_PATH . '/lib/nav.lib.php');
		
		$nav = new Nav($GLOBALS['SCup']->SCup_nav_file);
		
        $this->assign('navigation', $nav->_get_nav());	
        $pic_data = include(ROOT_PATH . '/data/cache/rollpic_'.trim($GLOBALS['Lang']->_lang_tp).'.php'); 
		$this->assign('pic_data', $pic_data);		
	    
        $this->assign('view_charset', VIEW_CHARSET);	
        $this->assign('page_title', SITE_TITLE);
        $this->assign('page_description', SITE_DESCRIPTION);
        $this->assign('page_keywords', SITE_KEYWORDS);	
		$this->assign('bg_pic_url',$GLOBALS['SCup']->SCup_name.'/view/'.VIEW_TYPE .'/style/'.CSS_TYPE.'/');			
        $this->assign('login_icon', $GLOBALS['SCup']->SCup_user_checking);
        $this->assign('langtype', trim($GLOBALS['Lang']->_lang_tp));
	        $this->assign('site_url',SITE_URL);	
        $this->assign('langdata', $GLOBALS['Lang']->_get_lang_typesdata());	 		
        $this->display('reg.view.html');
    }

    function regpost()
    {
		if ((!ALLOW_REGISTER) && ($GLOBALS['SCup']->SCup_name != 'admin')) 
		{   
	        $notice = &get_message(array('msg'=>CLOSE_REGISTER_REASON,'url'=>'','title'=>'提示'));
	        $notice ->display();
		}		
		$username = $_POST['username'];		
		$pwd =  $_POST['pwd'];
		$checkpwd =  $_POST['checkpwd'];		
		$emiall =  $_POST['emiall'];
						
		$cookie_yzimgnum = get_cookie('yzImgNum');
		$post_yzimgnum = $_POST['yzImgNum_s_yz'];
		$get_yzimgnum = $_GET['yzImgNum_s_yz'];
        $data=array();
        $data['username']=$username;
        $data['email']=$emiall;
        $data['password']=$pwd;
        $data['check_passwd']=$checkpwd;
	    $user = & $GLOBALS['SCup']->_get_user(); 						
	    if($user->reg($data))
		{
		
		 $notice = &get_message(array('msg'=>"注册成功!",'url'=>SITE_URL.'/?app=login&act=index','title'=>'Notice'));
		 $notice ->display();
		
		}
		else
		{


		 $notice = &get_message(array('msg'=>"注册失败!",'url'=>SITE_URL,'title'=>'Notice'));
		 $notice ->display();

		}
		

    }		
	
    function login()
    {
		
		$username = $_POST['username'];		
		$pwd =  $_POST['pwd'];
		$cookie_yzimgnum = get_cookie('yzImgNum');
		if(!isset($_POST['yzImgNum_s_yz']))
		{
		$_POST['yzImgNum_s_yz']='';
		}
		if(!isset($_GET['yzImgNum_s_yz']))
		{
		$_GET['yzImgNum_s_yz']='';
		}		
		
		$post_yzimgnum = $_POST['yzImgNum_s_yz'];
		$get_yzimgnum = $_GET['yzImgNum_s_yz'];

	    $user = & $GLOBALS['SCup']->_get_user(); 						
	    if($user->login($username,$pwd))
		{
		
          $this->index();
		
		}
		else
		{


		 $notice = &get_message(array('msg'=>"登入失败",'url'=>SITE_URL,'title'=>'Notice'));
		 $notice ->display();

		}
		

    }

    function quit()
    {
		
	   $user = & $GLOBALS['SCup']->_get_user();		
	   if($user->quit())
	   {
	   		$GLOBALS['SCup']->SCup_user_checking = false;
	   		$notice = &get_message(array('msg'=>"退出成功!",'url'=>SITE_URL.'/?app=login&act=index','title'=>'Notice', 'skip_time'=>500));
			$notice ->display();
	   }
	   else
	   {
	   $notice = &get_message(array('msg'=>'False!','url'=>'','title'=>'Notice'));
	   $notice ->display();	   
	   
	   }

	   
	   

    }
	
    function password()
    {
		$GLOBALS['Lang']->_get_lang('password');	
		require(ROOT_PATH . '/lib/nav.lib.php');
		
		$nav = new Nav($GLOBALS['SCup']->SCup_nav_file);
		
        $this->assign('navigation', $nav->_get_nav());	
        $pic_data = include(ROOT_PATH . '/data/cache/rollpic_'.trim($GLOBALS['Lang']->_lang_tp).'.php'); 
		$this->assign('pic_data', $pic_data);	
		
        $this->assign('view_charset', VIEW_CHARSET);	
        $this->assign('page_title', SITE_TITLE);
        $this->assign('page_description', SITE_DESCRIPTION);
        $this->assign('page_keywords', SITE_KEYWORDS);	
        $this->assign('langtype', trim($GLOBALS['Lang']->_lang_tp));
        $this->assign('langdata', $GLOBALS['Lang']->_get_lang_typesdata());	 			
        $this->assign('login_icon', $GLOBALS['SCup']->SCup_user_checking);			
		$this->assign('bg_pic_url',$GLOBALS['SCup']->SCup_name.'/view/'.VIEW_TYPE .'/style/'.CSS_TYPE.'/');	
	        $this->assign('site_url',SITE_URL);	
        $this->display('password.view.html');

    }	

    function editpwd()
    {
		
		$data = $_POST['data'];		
		unset($data['user_id']);				
		$data['user_id'] = $GLOBALS['SCup']->SCup_user_msg['user_id'];
				
		$user = & $GLOBALS['SCup']->_get_user();	
		
	   if($user->pwd($data))
	   {
	   $notice = &get_message(array('msg'=>'Succes!','url'=>'','title'=>'Notice'));
	   $notice ->display();		   
	   
	   }
	   else
	   {
	   $notice = &get_message(array('msg'=>'False!','url'=>'','title'=>'Notice'));
	   $notice ->display();		   
	   }
	   
    }	


    function user()
    {
		$GLOBALS['Lang']->_get_lang('login');	
		require(ROOT_PATH . '/lib/nav.lib.php');
		
		$nav = new Nav($GLOBALS['SCup']->SCup_nav_file);
		
        $this->assign('navigation', $nav->_get_nav());	
        $pic_data = include(ROOT_PATH . '/data/cache/rollpic_'.trim($GLOBALS['Lang']->_lang_tp).'.php'); 
		$this->assign('pic_data', $pic_data);	
		
        $this->assign('view_charset', VIEW_CHARSET);	
        $this->assign('page_title', SITE_TITLE);
        $this->assign('page_description', SITE_DESCRIPTION);
        $this->assign('page_keywords', SITE_KEYWORDS);	
			
        $this->assign('login_icon', $GLOBALS['SCup']->SCup_user_checking);	       
		 $this->assign('langtype', trim($GLOBALS['Lang']->_lang_tp));
	        $this->assign('site_url',SITE_URL);	
		$this->assign('bg_pic_url',SITE_URL.'/'.$GLOBALS['SCup']->SCup_name.'/view/'.VIEW_TYPE .'/style/'.CSS_TYPE.'/');	

      $this->display('user.view.html');

    }	

    function setting()
    {
	    
		$setingdata =array();
		$data = array();
		
		if(is_file(ROOT_PATH . '/data/companyconfig/config_'.COMPANY_ID.'.inc.php'))
		{
          include(ROOT_PATH . '/data/config_'.trim($GLOBALS['Lang']->_lang_tp).'.inc');
		  foreach($setingdata as $key => $value)
		  {
           $data[$key] = $value;		   
		  }		 
		 
		}
		else
		{
		  $TB_set = &$this->_model('setting'); 	
		  $setingdata = $TB_set->show();

		  foreach($setingdata as $key => $value)
		  {
           $data[$value['keyname']] = $value['value'];		   
		  }
	
		}
        
		if(empty($data))
		{
		  $TB_set = &$this->_model('setting'); 	
		  $setingdata = $TB_set->allshow();

		  foreach($setingdata as $key => $value)
		  {
           $data[$value['keyname']] = $value['value'];		   
		  }
		
		}

		!isset($data['waterimg_dir'])?$data['waterimg_dir']='':'';
		!isset($data['site_url'])?$data['site_url']='':'';
		!isset($data['site_title'])?$data['site_title']='':'';		
		!isset($data['site_keywords'])?$data['site_keywords']='':'';		
		!isset($data['site_description'])?$data['site_description']='':'';		
		!isset($data['miibeian'])?$data['miibeian']='':'';
		!isset($data['upfile_path'])?$data['upfile_path']='':'';		
		!isset($data['thumb_width'])?$data['thumb_width']='':'';		
		!isset($data['thumb_height'])?$data['thumb_height']='':'';			
		!isset($data['is_waterimg'])?$data['is_waterimg']='':'';
		!isset($data['max_file_size'])?$data['max_file_size']='':'';		
		!isset($data['upfile_types'])?$data['upfile_types']='':'';		
		!isset($data['enabled_gzip'])?$data['enabled_gzip']='':'';			
		!isset($data['system_url_rewrite'])?$data['system_url_rewrite']='':'';	
		!isset($data['system_url_html_rewrite'])?$data['system_url_html_rewrite']='':'';				
		!isset($data['version_info'])?$data['version_info']='':'';			
		!isset($data['system_open'])?$data['system_open']='':'';
		!isset($data['system_open_reason'])?$data['system_open_reason']='':'';		
		!isset($data['allow_register'])?$data['allow_register']='':'';		
		!isset($data['close_register_reason'])?$data['close_register_reason']='':'';			
		!isset($data['login_verycode'])?$data['login_verycode']='':'';		
		!isset($data['register_verycode'])?$data['register_verycode']='':'';		
		!isset($data['lang'])?$data['lang']='':'';		
		!isset($data['cookie_domain'])?$data['cookie_domain']='':'';		
		!isset($data['cookie_path'])?$data['cookie_path']='':'';		
		!isset($data['cookie_secure'])?$data['cookie_secure']='':'';		
		!isset($data['cookie_prefix'])?$data['cookie_prefix']='':'';		
		!isset($data['session_prefix'])?$data['session_prefix']='':'';		
		!isset($data['session_max_life_time'])?$data['session_max_life_time']='':'';
		!isset($data['cache_server'])?$data['cache_server']='':'';		
		!isset($data['user_type'])?$data['user_type']='':'';		
		!isset($data['view_type'])?$data['view_type']='':'';		
		!isset($data['css_type'])?$data['css_type']='':'';		
		!isset($data['enabled_subdomain'])?$data['enabled_subdomain']='':'';		
		!isset($data['subdomain_suffix'])?$data['subdomain_suffix']='':'';		
		!isset($data['system_mysql_session'])?$data['system_mysql_session']='':'';		
		!isset($data['encrypt_key'])?$data['encrypt_key']='':'';	
		!isset($data['away_use_keyword'])?$data['away_use_keyword']='':'';		
		!isset($data['away_use_zhandian'])?$data['away_use_zhandian']='':'';			
		!isset($data['qq_set_data'])?$data['qq_set_data']='':'';		
						
        $this->assign('data', $data);	
		
        $this->assign('view_charset', VIEW_CHARSET);	
        $this->assign('page_title', SITE_TITLE);
        $this->assign('page_description', SITE_DESCRIPTION);
        $this->assign('page_keywords', SITE_KEYWORDS);	
			
        $this->assign('login_icon', $GLOBALS['SCup']->SCup_user_checking);	       
		 $this->assign('langtype', trim($GLOBALS['Lang']->_lang_tp));
	        $this->assign('site_url',SITE_URL);	
		$this->assign('bg_pic_url',SITE_URL.'/'.$GLOBALS['SCup']->SCup_name.'/view/'.VIEW_TYPE .'/style/'.CSS_TYPE.'/');	
		 $this->display('setting.view.html');

    }

    function companypost()
    {
      if(!isset($_GET['action']))$_GET['action']='';
	  $action = $_GET['action'];
       if($action=='addpost')
	   {
          $data = $_POST['data'];
		  $fids = $_POST['fids'];
		  $str='';
          foreach($fids as $key => $value )
		  {
		   $str.=$value.':';
		  }
		  
		  $data['fname']=$str;
		  		  
		  if($_FILES['postfile1']['tmp_name'])
	      { 		
	       include(ROOT_PATH.'/lib/upfile.lib.php');	  
		   $upfile = new Upfile('company'); 	  
	       $updata = $upfile->_batch_upfile('company');
	   	   if(!empty($updata)&&isset($updata[1]['path']))
		   {
		     $data['picurl']=$updata[1]['path'];
		   }
          }		  
		  
		  $data['uid'] = $GLOBALS['SCup']->SCup_user_msg['user_id'];
		  $data['username'] = $GLOBALS['SCup']->SCup_user_msg['data']['user_name'];
		  $TB_company= &$this->_model('company');		 		 		
		  $TB_company->post($data);		  
	      $notice = &get_message(array('msg'=>'Succes!','url'=>'','title'=>'Notice'));
	      $notice ->display();			  	
	   }
       if($action=='getfidsonslist')
	   { 
	      $fup = $_GET['fup'];
		  $class = $_GET['class'];
		  $ctype = $_GET['ctype'];
		  $Murl = SITE_URL.'/company'; 
          header('Content-type: text/html; charset='.VIEW_CHARSET);	
	   
		  $companycategorydata = & $GLOBALS['SCup']->_get_category_data('company');
		  $icon_fup = true;	
		  foreach($companycategorydata as $key => $value)
		  {
		     if($value['parent_id']==$fup)
			 {
			  $icon_fup = false;	
			 }
		  }
	      if($icon_fup) echo "&nbsp;";
          $str='';
		  foreach($companycategorydata as $key => $value)
		  {
		     if($value['parent_id']==$fup)
			 {
		        $next='true';
		        $icon_fup = true;	
		        foreach($companycategorydata as $key1 => $value1)
		        {
		          if($value['cat_id']==$value1['parent_id'])
			      {
			       $icon_fup = false;	
			      }
		        }
				if($icon_fup || $class >= 4)
				{
				   $next = 'false';
				}
				$str.= "<div><a href=\"javascript:;\" onclick=\"changeClassName($class,this,".$value['cat_id'].",$next,$ctype ,\'$Murl\')\">".$value['cat_name']."</a></div>"; 				

			 }
		  }
	     $str=$str?$str:"&nbsp;";
	     echo '<script >parent.inputcontent(\''.$str.'\','.$class.');</script>';
	     exit;
	
       }	
		

	 	$companycategorydata = & $GLOBALS['SCup']->_get_category_data('company');	
        $this->assign('companycategorydata', $companycategorydata);	
		
        $this->assign('view_charset', VIEW_CHARSET);	
        $this->assign('page_title', SITE_TITLE);
        $this->assign('page_description', SITE_DESCRIPTION);
        $this->assign('page_keywords', SITE_KEYWORDS);	
			
        $this->assign('login_icon', $GLOBALS['SCup']->SCup_user_checking);	       
		 $this->assign('langtype', trim($GLOBALS['Lang']->_lang_tp));
	        $this->assign('site_url',SITE_URL);	
		$this->assign('bg_pic_url',SITE_URL.'/'.$GLOBALS['SCup']->SCup_name.'/view/'.VIEW_TYPE .'/style/'.CSS_TYPE.'/');	
		 $this->display('companypost.view.html');

    }

    function companymsg()
    {
      if(!isset($_GET['action']))$_GET['action']='';
	  $action = $_GET['action'];

       if($action=='getfidsonslist')
	   { 
	      $fup = $_GET['fup'];
		  $class = $_GET['class'];
		  $ctype = $_GET['ctype'];
		  $Murl = SITE_URL.'/company'; 
          header('Content-type: text/html; charset='.VIEW_CHARSET);	
	   
		  $companycategorydata = & $GLOBALS['SCup']->_get_category_data('company');
		  $icon_fup = true;	
		  foreach($companycategorydata as $key => $value)
		  {
		     if($value['parent_id']==$fup)
			 {
			  $icon_fup = false;	
			 }
		  }
	      if($icon_fup) echo "&nbsp;";
          $str='';
		  foreach($companycategorydata as $key => $value)
		  {
		     if($value['parent_id']==$fup)
			 {
		        $next='true';
		        $icon_fup = true;	
		        foreach($companycategorydata as $key1 => $value1)
		        {
		          if($value['cat_id']==$value1['parent_id'])
			      {
			       $icon_fup = false;	
			      }
		        }
				if($icon_fup || $class >= 4)
				{
				   $next = 'false';
				}
				$str.= "<div><a href=\"javascript:;\" onclick=\"changeClassName($class,this,".$value['cat_id'].",$next,$ctype ,\'$Murl\')\">".$value['cat_name']."</a></div>"; 				

			 }
		  }
	     $str=$str?$str:"&nbsp;";
	     echo '<script >parent.inputcontent(\''.$str.'\','.$class.');</script>';
	     exit;
	
       }	

		$TB_company= &$this->_model('company');		 		 		
		$companydata = $TB_company->oneshow($GLOBALS['SCup']->SCup_user_msg['user_id']);
        $this->assign('companydata', $companydata);			
        $fidsdata = $this->fidsstr($companydata['fname']);
        $this->assign('fidsdata', $fidsdata);						
		
	 	$companycategorydata = & $GLOBALS['SCup']->_get_category_data('company');	
			
        $this->assign('companycategorydata', $companycategorydata);	
		
        $this->assign('view_charset', VIEW_CHARSET);	
        $this->assign('page_title', SITE_TITLE);
        $this->assign('page_description', SITE_DESCRIPTION);
        $this->assign('page_keywords', SITE_KEYWORDS);	
			
        $this->assign('login_icon', $GLOBALS['SCup']->SCup_user_checking);	       
		$this->assign('langtype', trim($GLOBALS['Lang']->_lang_tp));
	    $this->assign('site_url',SITE_URL);	
		$this->assign('bg_pic_url',SITE_URL.'/'.$GLOBALS['SCup']->SCup_name.'/view/'.VIEW_TYPE .'/style/'.CSS_TYPE.'/');	
		$this->display('companymsg.view.html');

    }
    function companyrz()
    {
		$GLOBALS['Lang']->_get_lang('login');	
		require(ROOT_PATH . '/lib/nav.lib.php');
		
		$nav = new Nav($GLOBALS['SCup']->SCup_nav_file);
		
        $this->assign('navigation', $nav->_get_nav());	
        $pic_data = include(ROOT_PATH . '/data/cache/rollpic_'.trim($GLOBALS['Lang']->_lang_tp).'.php'); 
		$this->assign('pic_data', $pic_data);	
		
        $this->assign('view_charset', VIEW_CHARSET);	
        $this->assign('page_title', SITE_TITLE);
        $this->assign('page_description', SITE_DESCRIPTION);
        $this->assign('page_keywords', SITE_KEYWORDS);	
			
        $this->assign('login_icon', $GLOBALS['SCup']->SCup_user_checking);	       
		 $this->assign('langtype', trim($GLOBALS['Lang']->_lang_tp));
	        $this->assign('site_url',SITE_URL);	
		$this->assign('bg_pic_url',SITE_URL.'/'.$GLOBALS['SCup']->SCup_name.'/view/'.VIEW_TYPE .'/style/'.CSS_TYPE.'/');	
		 $this->display('companyrz.view.html');

    }
	
    function fidsstr($str='')
    {
        $array = explode(':',$str);
		return del_empty_var($array);

    }   
}






?>